package util;

import java.util.Comparator;
import java.util.Map;

public class RankComparable implements Comparator<Attributes> {

	@Override
	public int compare(Attributes a1, Attributes a2) {
	      if (a1.isReitOrTrust() && !a2.isReitOrTrust()) { 
	            return -1; 
	        } 
	      else if (!a1.isReitOrTrust() && a2.isReitOrTrust()) { 
	            return 1; 
	        } 
	      
		if (a1.getRating() != null || a2.getRating() != null) {
			if (a1.getRating() == null) {
				return 1;
			}
			else if (a2.getRating() == null) {
				return -1;
			}
			else if (a1.getRating().getRating() > a2.getRating().getRating()) { 
	            return -1; 
	        } 
	      else if (a1.getRating().getRating() < a2.getRating().getRating()) { 
	            return 1; 
	        } 
		}

	      if (a1.getTargetPrice() > a2.getTargetPrice()) { 
	            return -1; 
	        } 
	      else if (a1.getTargetPrice() < a2.getTargetPrice()) { 
	            return 1; 
	        } 

	      else if (a1.getHottness() > a2.getHottness()) { 
	            return -1; 
	        } 
	      else if (a1.getHottness() < a2.getHottness()) { 
	            return 1; 
	        } 

	      if (a1.getFeaturesSatisfied() > a2.getFeaturesSatisfied()) { 
	            return -1; 
	        } 
	      else if (a1.getFeaturesSatisfied() < a2.getFeaturesSatisfied()) { 
	            return 1; 
	        } 

	      if (a1.getEngulfingRatio() > a2.getEngulfingRatio()) { 
	            return -1; 
	        } 
	      else if (a1.getEngulfingRatio() < a2.getEngulfingRatio()) { 
	            return 1; 
	        } 

	      if (a1.isIs3BlackSoldiers() && !a2.isIs3BlackSoldiers()) { 
	            return -1; 
	        } 
	      else if (!a1.isIs3BlackSoldiers() && a2.isIs3BlackSoldiers()) { 
	            return 1; 
	        } 
	      
	      if (a1.isDoji() && !a2.isDoji()) { 
	            return -1; 
	        } 
	      else if (!a1.isDoji() && a2.isDoji()) { 
	            return 1; 
	        } 
	      
	      if (a1.getHammerRatio() > a2.getHammerRatio()) { 
	            return -1; 
	        } 
	      else if (a1.getHammerRatio() < a2.getHammerRatio()) { 
	            return 1; 
	        } 
	      
	      if (a1.getSupportedTicks() > a2.getSupportedTicks()) { 
	            return -1; 
	        } 
	      else if (a1.getSupportedTicks() < a2.getSupportedTicks()) { 
	            return 1; 
	        } 
	      
	      if (a1.isPriceLowReversed() && !a2.isPriceLowReversed()) { 
	            return -1; 
	        } 
	      else if (!a1.isPriceLowReversed() && a2.isPriceLowReversed()) { 
	            return 1; 
	        } 
	      
	      if (a1.isIs2WhiteSoldiers() && !a2.isIs2WhiteSoldiers()) { 
	            return -1; 
	        } 
	      else if (!a1.isIs2WhiteSoldiers() && a2.isIs2WhiteSoldiers()) { 
	            return 1; 
	        } 
	      
	      return 0;
	}
}
